/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package es.aurea.transferobjects;

import java.io.Serializable;
import java.util.HashMap;

/**
 *
 * @author zarius
 */
public class UserTO implements Serializable{

    private Integer id;

    private Integer version;

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    private String username;

    private String password;

    private HashMap<Integer,String> groupsCollection = new HashMap<Integer,String>();

    public UserTO(){

    }

    public UserTO(Integer id){
        this.id = id;
    }

    public UserTO(String username){
        this.username = username;
    }

    public UserTO(Integer id, String username){
        this.id = id;
        this.username = username;
    }

    public void copy(UserTO userTO){
        this.id = userTO.getId();
        this.username = userTO.getUsername();
        this.password = userTO.getPassword();
        this.groupsCollection = userTO.getGroupsCollection();
    }

    public boolean equals(UserTO userTO){

        if(userTO == null){
            return false;
        } else if (userTO.getId()!=this.getId()){
            return false;
        } else if (userTO.getUsername()!=null && !userTO.getUsername().equals(this.getUsername())){
            return false;
        } else if (userTO.getPassword()!=null && !userTO.getPassword().equals(this.getPassword())){
            return false;
        } else if (userTO.getGroupsCollection()!=null && !userTO.getGroupsCollection().equals(this.getGroupsCollection())){
            return false;
        }
        return true;

    }

    public String getGroupoName(Integer key) {
        return groupsCollection.get(key);
    }

    public HashMap<Integer,String> getGroupsCollection(){
        return groupsCollection;
    }
    public void setGroupoName(Integer key, String name) {
        groupsCollection.put(key, name);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
